package com.lianrui.app.member.controller;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianrui.app.member.domain.Subject;
import com.lianrui.app.member.service.ISubjectService;
import com.lianrui.app.member.vos.SubjectPage;
import com.lianrui.commons.ResultView;
import com.lianrui.core.AbstractController;
import com.lianrui.core.IService;

/**
 * 主体信息接口
 * 
 * @ClassName: SubjectController <br/>
 * @Function: TODO ADD FUNCTION. <br/>
 * @Reason: TODO ADD REASON(可选). <br/>
 * @date: 2016年1月19日 上午11:51:19 <br/>
 * 
 * @author Yefq
 * @version
 *
 */
@Controller
@RequestMapping("/subject")
public class SubjectController extends AbstractController<SubjectPage, Subject, Integer> {

    private static final Logger LOGGER = LoggerFactory
            .getLogger(SubjectController.class);

    @Autowired
    ISubjectService subjectService;

    @Override
    public IService<SubjectPage, Subject, Integer> getService() {
        // TODO Auto-generated method stub
        return subjectService;
    }

    @Override
    public Logger getLogger() {
        // TODO Auto-generated method stub
        return LOGGER;
    }
    
    /**
     * 根据memberId查询相应的主体列表
     * 
     * @Method: list
     * @Description: TODO
     * @param @param
     *            memberId
     * @param @param
     *            page
     * @param @return
     * @return SubjectPage
     * @throws @param
     *             memberId
     * @throws @param
     *             page
     * @throws @return
     *
     * @author Yefq
     * @date 2016 2016年1月19日 下午2:42:12
     */
    @RequestMapping("/list/{memberId}")
    @ResponseBody
    public SubjectPage list(@PathVariable Integer memberId, SubjectPage page) {
        page.setMemberId(memberId);
        Map<String, String> expands = new HashMap<String, String>();
        expands.put("member_id", memberId.toString());
        page.setExpands(expands);
        return super.list(page);
    }

    
    @RequestMapping("/add/{memberId}")
    @ResponseBody
    public ResultView<Integer> add(@PathVariable Integer memberId, Subject d) {
        d.setMember_id(memberId);
        return super.add(d);
    }

    
    @RequestMapping("/update/{memberId}")
    @ResponseBody
    public ResultView<Void> update(@PathVariable Integer memberId, Subject d) {
        d.setMember_id(memberId);
        return super.update(d);
    }
    
    

}
